//
//  ViewController.m
//  SYPullShapeView
//
//  Created by 王声远 on 16/8/23.
//  Copyright © 2016年 创美汇. All rights reserved.
//

#import "ViewController.h"
#import "SYZNView.h"

@interface ViewController ()<UITableViewDataSource,UITableViewDelegate>

@property (weak,nonatomic) UITableView *myTableView;
@property (nonatomic,strong) NSMutableArray *datas;
@property (nonatomic,strong) SYZNView *heartView;

@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    self.title = @"项目上下拉刷新";
    
    self.heartView = [[SYZNView alloc]initWithFrame:CGRectMake((self.view.frame.size.width-heartWidth)/2, 20, heartWidth, heartHeight)];
    [self.view addSubview:self.heartView];
    self.heartView.fillColor = [UIColor orangeColor];
    
    //初始化tableview并添加到界面上
    CGRect mainFrame =self.view.bounds;
    mainFrame.origin.y = (CGRectGetHeight(self.heartView.frame));
    mainFrame.size.height -= (CGRectGetHeight(self.heartView.frame));
    UITableView *myTableView = [[UITableView alloc] initWithFrame:mainFrame style:UITableViewStylePlain];
    [self.view addSubview:myTableView];
    self.myTableView = myTableView;
    self.myTableView.delegate = self;
    self.myTableView.dataSource = self;
    self.myTableView.rowHeight = 44;
    [self.myTableView setShowsVerticalScrollIndicator:NO];
    //去掉tableviewcell之间的分割线
    //self.myTableView.separatorStyle = UITableViewCellSeparatorStyleNone;
    
    self.myTableView.tableFooterView = [UIView new];
    
    //添加头部刷新
    [self setUpHeadReflesh];
    
    //添加尾部刷新
    [self setUpFootReflesh];
}

- (NSMutableArray *)datas
{
    if (_datas == nil) {
        _datas = [NSMutableArray array];
        [_datas addObject:@"你好"];
        [_datas addObject:@"你好"];
        [_datas addObject:@"你好"];
        [_datas addObject:@"你好"];
        [_datas addObject:@"你好"];
    }
    return _datas;
}

#pragma mark - 数据源方法
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return self.datas.count;
}

// 每一行的cell数据内容显示
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    static NSString *ID = @"KeyModeCellID";
    
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:ID];
    if (cell == nil) {
        cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:ID];
    }
    NSString *str = self.datas[indexPath.row];
    cell.textLabel.text = str;
    
    return cell;
}

- (void)scrollViewDidScroll:(UIScrollView *)scrollView {
    CGFloat f = scrollView.contentOffset.y / -100.0;
    self.heartView.rate = f;
}

- (void)setUpHeadReflesh
{
    
}

- (void)setUpFootReflesh
{
    
}


@end
